<template>
	<view class="drawer">
		<view class="background" v-if="open">
			<view class="drop" :style="{
				top: screenWidth <= 390 ? '56%' :'57%' 
			}" :class="{ close: isClose ,'drawer-open': open }">
				<view class="head">
					<view class="text">
						立即退役
					</view>
					<uni-icons @click="closeDrop" class="icon" type="closeempty" size="24"></uni-icons>
				</view>

				<view class="box1" :style="{height:'36px'}">
					<view class="item">
						<view class="title">
							退役日期
						</view>
						<view class="inpt">
							<uni-datetime-picker type="date" :clear-icon="false" v-model="use_date"
								@maskClick="maskClick" />
						</view>
					</view>
				</view>
				<view class="box1" :style="{height:'36px'}">
					<view class="item">
						<view class="title">
							回血价格
						</view>
						<view class="inpt">
							<input type="number" v-model="sell_price" placeholder="0" />
						</view>
					</view>
				</view>

				<view class="btncont">
					<button class="btn" @click="retirement">立即退役</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: ['open', 'Flowid', 'screenWidth'],
		data() {
			return {
				isClose: false,
				sell_price: 0,
				use_date: ''
			}
		},
		onLoad() {

		},
		methods: {
			retirement() {
				this.$api.update_statusApi({
					id: this.Flowid,
					sell_price: this.sell_price,
					use_date: this.use_date
				}).then(res => {
					if (res.code == 1) {
						uni.showToast({
							title: '退役成功'
						})
						this.$emit('closeRet')
						uni.switchTab({
							url: '/pages/tabBar/goods/goods'
						});
					}
				});
			},
			// 控制点击遮罩关闭抽屉
			closeDrop() {
				this.isClose = true;
				this.$emit('isClose')
			}
		}
	}
</script>
<style scoped lang="scss">
	.background {
		// z-index 控制是全屏还是半屏，即是否占顶部导航栏的位置
		z-index: 9999;
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		// 遮罩颜色
		background: rgba($color: #000000, $alpha: 0.5);
		// transition: bottom 0.3s ease-in-out;

		/* 过渡效果 */
		.drop {
			width: 100%;
			height: 100%;
			position: absolute;
			bottom: 0;
			top: 60%;
			right: 0;
			z-index: 999;
			background: #fff;
			border-radius: 14px 14px 0px 0px;

			.head {
				margin: 20px 0;
				position: relative;

				.icon {
					position: absolute;
					right: 14px;
					top: 0;
				}

				.text {
					font-family: 'Roboto';
					font-weight: 500;
					font-size: 21px;
					color: #3D3D3D;
					text-align: center;
				}
			}
		}

		.box1 {
			height: 110px;
			padding: 20px;
			background: #FFFFFF;
			border-radius: 6px 6px 6px 6px;
			margin: 10px 20px;
			border: 1px solid #C8CED2;

			.item:last-child {
				border-bottom: 0;
				padding-bottom: 0px;
			}

			.item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				border-bottom: 1px solid #D8D8D8;
				// margin-bottom: 20px;
				padding-bottom: 10px;

				.title {
					font-weight: 500;
					font-size: 16px;
					color: #5E5E5E;
				}

				.inpt {
					width: 180px;
				}
			}
		}

		.btncont {
			margin-left: 20px;
			margin-right: 20px;
			margin-top: 7%;

			.btn {
				color: #fff;
				background: linear-gradient(180deg, #637BE9 0%, #637BE9 100%);
			}
		}

		.drawer-open {
			bottom: 0;
			/* 打开时位置在屏幕底部 */
		}

		// 开
		.active {
			animation: bottom 0.5s normal forwards;
		}
	}
</style>